/**
 * 开发环境
 */
; (function () {
    window.SITE_CONFIG = {}

    // api接口请求地址
    window.SITE_CONFIG['baseUrl'] = 'http://localhost:8080/factory-timer'

    // cdn地址 = 域名 + 版本号
    window.SITE_CONFIG['domain'] = './' // 域名
    window.SITE_CONFIG['version'] = ''   // 版本号(年月日时分)
    window.SITE_CONFIG['cdnUrl'] = window.SITE_CONFIG.domain + window.SITE_CONFIG.version

    // if (navigator.userAgent.indexOf('Chrome') > -1) {
    //     alert("为了打印效果更佳推荐使用IE浏览器或者打开浏览器兼容模式")
    // }
})()


let jsonst = {
    "unqualifiedDescription1": "",
    "unqualifiedDescription2": "",
    "unqualifiedDescription3": "",
    "unqualifiedDescription4": "",
    "unqualifiedDescription5": "",
    "unqualifiedDescription6": "",
    "unqualifiedDescription7": "",
    "unqualifiedDescription8": "",
    "unqualifiedDescription9": "",
    "unqualifiedDescription10": "",
    "unqualifiedDescription11": "",
    "unqualifiedDescription12": "",
    "unqualifiedDescription13": "",
    "unqualifiedDescription14": "",
    "unqualifiedDescription15": "",
    "unqualifiedDescription16": "",
    "unqualifiedDescription17": "",
    "unqualifiedDescription18": "",
    "unqualifiedDescription19": "",
    "unqualifiedDescription20": "",
    "unqualifiedDescription21": "",
    "unqualifiedDescription22": "",
    "unqualifiedDescription23": "",
    "unqualifiedDescription24": "",
    "unqualifiedDescription25": "",
    "unqualifiedDescription26": "",
    "unqualifiedDescription27": "",
    "unqualifiedDescription28": "",
    "unqualifiedDescription29": "",
    "unqualifiedDescription30": "",
    "unqualifiedDescription31": "",
    "unqualifiedDescription32": "",
    "unqualifiedDescription33": "",
    "unqualifiedDescription34": "",
    "unqualifiedDescription35": "",
    "unqualifiedDescription36": "",
    "unqualifiedDescription37": "",
    "unqualifiedDescription38": "",
    "unqualifiedDescription39": "",
    "unqualifiedDescription40": "",
    "unqualifiedDescription41": "",
    "unqualifiedDescription42": "",
    "unqualifiedDescription43": "",
    "unqualifiedDescription44": "",
    "unqualifiedDescription45": "",
    "unqualifiedDescription46": "",
    "unqualifiedDescription47": "",
    "unqualifiedDescription48": "",
    "unqualifiedDescription49": "",
    "unqualifiedDescription50": "",
    "unqualifiedDescription51": "",
    "unqualifiedDescription52": "",
    "unqualifiedDescription53": "",
    "unqualifiedDescription54": "",
    "unqualifiedDescription55": "",
    "unqualifiedDescription56": "",
    "unqualifiedDescription57": "",
    "unqualifiedDescription58": "",
    "unqualifiedDescription59": "",
    "unqualifiedDescription60": "",
    "unqualifiedDescription61": "",
    "unqualifiedDescription62": "",
    "unqualifiedDescription63": "",
    "unqualifiedDescription64": "",
    "unqualifiedDescription65": "",
    "unqualifiedDescription66": "",
    "unqualifiedDescription67": "",
    "unqualifiedDescription68": "",
    "unqualifiedDescription69": "",
    "unqualifiedDescription70": "",
    "unqualifiedDescription71": "",
    "unqualifiedDescription72": "",
    "unqualifiedDescription73": "",

    "2isAgreement": "",
    "3content": "",
    "4name": "",
    "6instructions": "",
    "6specifications": "",
    "8reason": "",
    "12instructions": "",
    "12screen": "",
    "13instructions": "",
    "13controller": "",
    "14content": "",
    "15reason": "",
    "16makingName": "",
    "20specifications": "",
    "20highPressure": "",
    "21power": "",
    "21controller": "",
    "22key": "",
    "22pcb": "",
    "23pcb1": "",
    "23pcb2": "",
    "24project": "",
    "25bracket": "",
    "25pelvicShelf": "",
    "25hardware": "",
    "26pcb": "",
    "26plasticCement": "",
    "26other": "",
    "27project": "",
    "31specifications": "",
    "32count": "",
    "36version": "",
    "36name": "",
    "37temperature": "",
    "39value1": "",
    "39value2": "",
    "39value3": "",
    "39value4": "",
    "39value5": "",
    "39value6": "",
    "40version": "",
    "41dsub": "",
    "41dvi": "",
    "41dp": "",
    "41hdmi": "",
    "42fw": "",
    "43xy": "",
    "43productA": "",
    "43productB": "",
    "44lv": "",
    "44product": "",
    "45value1": "",
    "45value2": "",
    "45value3": "",
    "45value4": "",
    "45value5": "",
    "45value6": "",
    "46count": "",
    "48name": "",
    "48version": "",
    "49fw": "",
    "50version": "",
    "50name": "",
    "51type": "",
    "52count": "",
    "52current": "",
    "59targetValue": "",
    "59actualValue": "",
    "61count": "",
    "63count": "",
    "63enclosure": "",
    "64reason": "",
    "66size": "",
    "73name": "",
    "unhealthyDescription1": "",
    "unhealthyCount1": "",
    "stopStartTime1": "",
    "stopEndTime1": "",
    "resolveMethod1": "",
    "unhealthyDescription2": "",
    "unhealthyCount2": "",
    "stopStartTime2": "",
    "stopEndTime12": "",
    "resolveMethod2": "",
    "badMattersConfirmation": ""
}

let jsonText = {

    // "unqualifiedDescription1": 1,
    // "unqualifiedDescription2": 1,
    // "unqualifiedDescription3": 1,
    // "unqualifiedDescription4": 1,
    // "unqualifiedDescription5": 1,
    // "unqualifiedDescription6": 1,
    // "unqualifiedDescription7": 1,
    // "unqualifiedDescription8": 1,
    // "unqualifiedDescription9": 1,
    // "unqualifiedDescription10": 1,
    // "unqualifiedDescription11": 1,
    // "unqualifiedDescription12": 1,
    // "unqualifiedDescription13": 1,
    // "unqualifiedDescription14": 1,
    // "unqualifiedDescription15": 1,
    // "unqualifiedDescription16": 1,
    // "unqualifiedDescription17": 1,
    // "unqualifiedDescription18": 1,
    // "unqualifiedDescription19": 1,
    // "unqualifiedDescription20": 1,
    // "unqualifiedDescription21": 1,
    // "unqualifiedDescription22": 1,
    // "unqualifiedDescription23": 1,
    // "unqualifiedDescription24": 1,
    // "unqualifiedDescription25": 1,
    // "unqualifiedDescription26": 1,
    // "unqualifiedDescription27": 1,
    // "unqualifiedDescription28": 1,
    // "unqualifiedDescription29": 1,
    // "unqualifiedDescription30": 1,
    // "unqualifiedDescription31": 1,
    // "unqualifiedDescription32": 1,
    // "unqualifiedDescription33": 1,
    // "unqualifiedDescription34": 1,
    // "unqualifiedDescription35": 1,
    // "unqualifiedDescription36": 1,
    // "unqualifiedDescription37": 1,
    // "unqualifiedDescription38": 1,
    // "unqualifiedDescription39": 1,
    // "unqualifiedDescription40": 1,
    // "unqualifiedDescription41": 1,
    // "unqualifiedDescription42": 1,
    // "unqualifiedDescription43": 1,
    // "unqualifiedDescription44": 1,
    // "unqualifiedDescription45": 1,
    // "unqualifiedDescription46": 1,
    // "unqualifiedDescription47": 1,
    // "unqualifiedDescription48": 1,
    // "unqualifiedDescription49": 1,
    // "unqualifiedDescription50": 1,
    // "unqualifiedDescription51": 1,
    // "unqualifiedDescription52": 1,
    // "unqualifiedDescription53": 1,
    // "unqualifiedDescription54": 1,
    // "unqualifiedDescription55": 1,
    // "unqualifiedDescription56": 1,
    // "unqualifiedDescription57": 1,
    // "unqualifiedDescription58": 1,
    // "unqualifiedDescription59": 1,
    // "unqualifiedDescription60": 1,
    // "unqualifiedDescription61": 1,
    // "unqualifiedDescription62": 1,
    // "unqualifiedDescription63": 1,
    // "unqualifiedDescription64": 1,
    // "unqualifiedDescription65": 1,
    // "unqualifiedDescription66": 1,
    // "unqualifiedDescription67": 1,
    // "unqualifiedDescription68": 1,
    // "unqualifiedDescription69": 1,
    // "unqualifiedDescription70": 1,
    // "unqualifiedDescription71": 1,
    // "unqualifiedDescription72": 1,
    // "unqualifiedDescription73": 1,

    "2isAgreement": 1,
    "3content": 1,
    "4name": 1,
    "6instructions": 1,
    "6specifications": 1,
    "8reason": 1,
    "12instructions": 1,
    "12screen": 1,
    "13instructions": 1,
    "13controller": 1,
    "14content": 1,
    "15reason": 1,
    "16makingName": 1,
    "20highPressure": 1,
    "21controller": 1,
    "22pcb": 1,
    "23pcb2": 1,
    "24project": 1,
    "25bracket": 1,
    "25pelvicShelf": 1,
    "25hardware": 1,
    "26pcb": 1,
    "26plasticCement": 1,
    "26other": 1,
    "27project": 1,
    "31specifications": 1,
    "32count": 1,
    "37temperature": 1,
    "39value4": 0,
    "39value5": 0,
    "39value6": 0,
    "40version": 1,
    "41dsub": 0,
    "41dvi": 0,
    "41dp": 0,
    "41hdmi": 0,
    "42fw": 1,
    "43productA": 0,
    "43productB": 0,
    "44product": 1,
    "45value4": 0,
    "45value5": 0,
    "45value6": 0,
    "46count": 1,
    "48name": 0,
    "48version": 0,
    "49fw": 1,
    "50version": 0,
    "50name": 0,
    "51type": 1,
    "52count": 1,
    "52current": 1,
    "59actualValue": 1,
    "61count": 1,
    "63count": 0,
    "63enclosure": 0,
    "64reason": 1,
    "66size": 1,
    // "unhealthyDescription1": 1,
    // "unhealthyCount1": 1,
    // "stopStartTime1": 1,
    // "stopEndTime1": 1,
    // "resolveMethod1": 1,
    // "unhealthyDescription2": 1,
    // "unhealthyCount2": 1,
    // "stopStartTime2": 1,
    // "stopEndTime12": 1,
    // "resolveMethod2": 1,
    // "badMattersConfirmation": 1
}

console.log(window.SITE_CONFIG['baseUrl'])

const http = axios.create({
    timeout: 1000 * 30,
    withCredentials: true,
    headers: {
        'Content-Type': 'application/json; charset=utf-8'
    }
})

function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

/**
  * 请求地址处理
  * @param {*} actionName action方法名称
  */
http.adornUrl = (actionName) => {
    // 非生产环境 && 开启代理, 接口前缀统一使用[/proxyApi/]前缀做代理拦截!
    return (process.env.NODE_ENV !== 'production' && process.env.OPEN_PROXY ? '/proxyApi/' : window.SITE_CONFIG.baseUrl) + actionName
}

/**
 * get请求参数处理
 * @param {*} params 参数对象
 * @param {*} openDefultParams 是否开启默认参数?
 */
http.adornParams = (params = {}, openDefultParams = true) => {
    var defaults = {
        't': new Date().getTime()
    }
    return openDefultParams ? merge(defaults, params) : params
}

/**
 * post请求数据处理
 * @param {*} data 数据对象
 * @param {*} openDefultdata 是否开启默认数据?
 * @param {*} contentType 数据格式
 *  json: 'application/json; charset=utf-8'
 *  form: 'application/x-www-form-urlencoded; charset=utf-8'
 */
http.adornData = (data = {}, openDefultdata = true, contentType = 'json') => {
    var defaults = {
        't': new Date().getTime()
    }
    data = openDefultdata ? merge(defaults, data) : data
    return contentType === 'json' ? JSON.stringify(data) : qs.stringify(data)
}

let app = new Vue({
    el: "#report",
    data: {
        riContent: {}
    },
    created() {
        http
            .get(window.SITE_CONFIG['baseUrl'] + "/sys/report/ipqcReport?id=" + getQueryString("id"))
            .then(response => {
                console.log(response)
                console.log(response.data)

                //---------------------------------------
                this.riContent = JSON.parse(response.data.reportIPQC.riContent)
                console.log(this.riContent)
                console.log(this.riContent["2isAgreement"])
                setOkOrNg(this.riContent)
                setContent(this.riContent)
            })
            .catch(function (error) { // 请求失败处理
                console.log(error);
            });
    },
    methods: {
        saveReport: function () {
            console.log(this.riContent)
            let requestData = JSON.parse(JSON.stringify(this.riContent))
            let _this = this
            // this.riContent["2isAgreement"] = "力扭1231231";
            // this.riContent["3content"] = "";
            // this.riContent["4name"] = "";
            // this.riContent["6instructions"] = "";
            // this.riContent["6specifications"] = "";
            // this.riContent["8reason"] = "";
            // this.riContent["12instructions"] = "";
            // this.riContent["12screen"] = "";
            // this.riContent["13instructions"] = "";
            // this.riContent["13controller"] = "";
            // this.riContent["14content"] = "";
            // this.riContent["15reason"] = "";
            // this.riContent["16makingName"] = "";
            // this.riContent["20specifications"] = "";
            // this.riContent["20highPressure"] = "";
            // this.riContent["21power"] = "";
            // this.riContent["21controller"] = "";
            // this.riContent["22key"] = "";
            // this.riContent["22pcb"] = "";
            // this.riContent["23pcb1"] = "";
            // this.riContent["23pcb2"] = "";
            // this.riContent["24project"] = "";
            // this.riContent["25bracket"] = "";
            // this.riContent["25pelvicShelf"] = "";
            // this.riContent["25hardware"] = "";
            // this.riContent["26pcb"] = "";
            // this.riContent["26plasticCement"] = "";
            // this.riContent["26other"] = "";
            // this.riContent["27project"] = "";
            // this.riContent["31specifications"] = "";
            // this.riContent["32count"] = "";
            // this.riContent["36version"] = "";
            // this.riContent["36name"] = "";
            // this.riContent["37temperature"] = "";
            // this.riContent["39value1"] = "";
            // this.riContent["39value2"] = "";
            // this.riContent["39value3"] = "";
            // this.riContent["39value4"] = "";
            // this.riContent["39value5"] = "";
            // this.riContent["39value6"] = "";
            // this.riContent["40version"] = "";
            // this.riContent["41dsub"] = "";
            // this.riContent["41dvi"] = "";
            // this.riContent["41dp"] = "";
            // this.riContent["41hdmi"] = "";
            // this.riContent["42fw"] = "";
            // this.riContent["43xy"] = "";
            // this.riContent["43productA"] = "";
            // this.riContent["43productB"] = "";
            // this.riContent["44lv"] = "";
            // this.riContent["44product"] = "";
            // this.riContent["45value1"] = "";
            // this.riContent["45value2"] = "";
            // this.riContent["45value3"] = "";
            // this.riContent["45value4"] = "";
            // this.riContent["45value5"] = "";
            // this.riContent["45value6"] = "";
            // this.riContent["46count"] = "";
            // this.riContent["48name"] = "";
            // this.riContent["48version"] = "";
            // this.riContent["49fw"] = "";
            // this.riContent["50version"] = "";
            // this.riContent["50name"] = "";
            // this.riContent["51type"] = "";
            // this.riContent["52count"] = "";
            // this.riContent["52current"] = "";
            // this.riContent["59targetValue"] = "";
            // this.riContent["59actualValue"] = "";
            // this.riContent["61count"] = "";
            // this.riContent["63count"] = "";
            // this.riContent["63enclosure"] = "";
            // this.riContent["64reason"] = "";
            // this.riContent["66size"] = "";
            // this.riContent["73name"] = "";
            // this.riContent["unhealthyDescription1"] = "";
            // this.riContent["unhealthyCount1"] = "";
            // this.riContent["stopStartTime1"] = "";
            // this.riContent["stopEndTime1"] = "";
            // this.riContent["resolveMethod1"] = "";
            // this.riContent["unhealthyDescription2"] = "";
            // this.riContent["unhealthyCount2"] = "";
            // this.riContent["stopStartTime2"] = "";
            // this.riContent["stopEndTime12"] = "";
            // this.riContent["resolveMethod2"] = "";


            let jsonst = {
                "unqualifiedDescription1": "",
                "unqualifiedDescription2": "",
                "unqualifiedDescription3": "",
                "unqualifiedDescription4": "",
                "unqualifiedDescription5": "",
                "unqualifiedDescription6": "",
                "unqualifiedDescription7": "",
                "unqualifiedDescription8": "",
                "unqualifiedDescription9": "",
                "unqualifiedDescription10": "",
                "unqualifiedDescription11": "",
                "unqualifiedDescription12": "",
                "unqualifiedDescription13": "",
                "unqualifiedDescription14": "",
                "unqualifiedDescription15": "",
                "unqualifiedDescription16": "",
                "unqualifiedDescription17": "",
                "unqualifiedDescription18": "",
                "unqualifiedDescription19": "",
                "unqualifiedDescription20": "",
                "unqualifiedDescription21": "",
                "unqualifiedDescription22": "",
                "unqualifiedDescription23": "",
                "unqualifiedDescription24": "",
                "unqualifiedDescription25": "",
                "unqualifiedDescription26": "",
                "unqualifiedDescription27": "",
                "unqualifiedDescription28": "",
                "unqualifiedDescription29": "",
                "unqualifiedDescription30": "",
                "unqualifiedDescription31": "",
                "unqualifiedDescription32": "",
                "unqualifiedDescription33": "",
                "unqualifiedDescription34": "",
                "unqualifiedDescription35": "",
                "unqualifiedDescription36": "",
                "unqualifiedDescription37": "",
                "unqualifiedDescription38": "",
                "unqualifiedDescription39": "",
                "unqualifiedDescription40": "",
                "unqualifiedDescription41": "",
                "unqualifiedDescription42": "",
                "unqualifiedDescription43": "",
                "unqualifiedDescription44": "",
                "unqualifiedDescription45": "",
                "unqualifiedDescription46": "",
                "unqualifiedDescription47": "",
                "unqualifiedDescription48": "",
                "unqualifiedDescription49": "",
                "unqualifiedDescription50": "",
                "unqualifiedDescription51": "",
                "unqualifiedDescription52": "",
                "unqualifiedDescription53": "",
                "unqualifiedDescription54": "",
                "unqualifiedDescription55": "",
                "unqualifiedDescription56": "",
                "unqualifiedDescription57": "",
                "unqualifiedDescription58": "",
                "unqualifiedDescription59": "",
                "unqualifiedDescription60": "",
                "unqualifiedDescription61": "",
                "unqualifiedDescription62": "",
                "unqualifiedDescription63": "",
                "unqualifiedDescription64": "",
                "unqualifiedDescription65": "",
                "unqualifiedDescription66": "",
                "unqualifiedDescription67": "",
                "unqualifiedDescription68": "",
                "unqualifiedDescription69": "",
                "unqualifiedDescription70": "",
                "unqualifiedDescription71": "",
                "unqualifiedDescription72": "",
                "unqualifiedDescription73": "",

                "2isAgreement": "",
                "3content": "",
                "4name": "",
                "6instructions": "",
                "6specifications": "",
                "8reason": "",
                "12instructions": "",
                "12screen": "",
                "13instructions": "",
                "13controller": "",
                "14content": "",
                "15reason": "",
                "16makingName": "",
                "20specifications": "",
                "20highPressure": "",
                "21power": "",
                "21controller": "",
                "22key": "",
                "22pcb": "",
                "23pcb1": "",
                "23pcb2": "",
                "24project": "",
                "25bracket": "",
                "25pelvicShelf": "",
                "25hardware": "",
                "26pcb": "",
                "26plasticCement": "",
                "26other": "",
                "27project": "",
                "31specifications": "",
                "32count": "",
                "36version": "",
                "36name": "",
                "37temperature": "",
                "39value1": "",
                "39value2": "",
                "39value3": "",
                "39value4": "",
                "39value5": "",
                "39value6": "",
                "40version": "",
                "41dsub": "",
                "41dvi": "",
                "41dp": "",
                "41hdmi": "",
                "42fw": "",
                "43xy": "",
                "43productA": "",
                "43productB": "",
                "44lv": "",
                "44product": "",
                "45value1": "",
                "45value2": "",
                "45value3": "",
                "45value4": "",
                "45value5": "",
                "45value6": "",
                "46count": "",
                "48name": "",
                "48version": "",
                "49fw": "",
                "50version": "",
                "50name": "",
                "51type": "",
                "52count": "",
                "52current": "",
                "59targetValue": "",
                "59actualValue": "",
                "61count": "",
                "63count": "",
                "63enclosure": "",
                "64reason": "",
                "66size": "",
                "73name": "",
                "unhealthyDescription1": "",
                "unhealthyCount1": "",
                "stopStartTime1": "",
                "stopEndTime1": "",
                "resolveMethod1": "",
                "unhealthyDescription2": "",
                "unhealthyCount2": "",
                "stopStartTime2": "",
                "stopEndTime12": "",
                "resolveMethod2": "",
                "badMattersConfirmation": ""
            }


            Object.keys(jsonst).forEach(function (v) {
                // console.log(v)
                requestData[v] = $("#" + v).text();
            })


            http({
                url: window.SITE_CONFIG['baseUrl'] + "/sys/report/updateIpqcReport",
                method: "post",
                data: {
                    riId: getQueryString("id"),

                    // riId: 2,
                    riContent: JSON.stringify(requestData)
                }

            })
                .then(response => {
                    console.log(response)
                    console.log(response.data)
                    if (response.data.code == 0) {
                        alert("保存成功")
                    } else {
                        alert("保存失败，请联系管理员")
                    }
                })
                .catch(function (error) { // 请求失败处理
                    console.log(error);
                    alert("保存失败，请检查网络")
                });
        }
    }
})


function isOkTime(e, num) {
    let serialTime = $(e).parent("div").parent(".serial-box").data("serialTime")
    // console.log(serialTime)
    if (num == 1 && app.$data.riContent[serialTime] != "1") {
        app.$data.riContent[serialTime] = "1"
    } else if (num == 2 && app.$data.riContent[serialTime] != "2") {
        app.$data.riContent[serialTime] = "2"
    } else {
        app.$data.riContent[serialTime] = "0"
    }
    // console.log(app.$data.riContent[serialTime])
    // $(e).parent("div").parent(".serial-box").html()
}
function isOkTime2(e) {
    let serialTime = $(e).data("serialTime")
    // console.log(app.$data.riContent[serialTime])
    if (app.$data.riContent[serialTime] == "0" || app.$data.riContent[serialTime] == "2") {
        app.$data.riContent[serialTime] = "1"
        $(e).attr("src", './img/ic_check_checked.png')
        $(e).parent().next().children("img").attr("src", './img/ic_check_default.png')
    } else {
        app.$data.riContent[serialTime] = "0"
        $(e).attr("src", './img/ic_check_default.png')
    }
}

function isNgTime2(e) {
    let serialTime = $(e).data("serialTime")
    // console.log(app.$data.riContent[serialTime])
    if (app.$data.riContent[serialTime] == "0" || app.$data.riContent[serialTime] == "1") {
        app.$data.riContent[serialTime] = "2"
        $(e).attr("src", './img/ic_check_checked.png')
        $(e).parent().prev().children("img").attr("src", './img/ic_check_default.png')
    } else {
        app.$data.riContent[serialTime] = "0"
        $(e).attr("src", './img/ic_check_default.png')
    }
    let json = app.$data.riContent[serialTime]
}


function setOkOrNg(json) {
    let num1 = 1;
    let num2 = 1;
    let html = '';
    let img = '';
    Object.keys(json).forEach(function (v, k) {

        if (v == "serial" + num1 + "Time" + num2) {
            html =
                `<div class="serial-box" data-serialTime="serial${num1}Time${num2}">
                    <div>
                        <div>OK</div>
                        <img data-serialTime="serial${num1}Time${num2}" onclick="isOkTime2(this)" src="${json["serial" + num1 + "Time" + num2] == '1' ? './img/ic_check_checked.png' : './img/ic_check_default.png'}" alt="">
                    </div>
                    <div>
                        <div>NG</div>
                        <img data-serialTime="serial${num1}Time${num2}" onclick="isNgTime2(this)" src="${json["serial" + num1 + "Time" + num2] == '2' ? './img/ic_check_checked.png' : './img/ic_check_default.png'}" alt="">
                    </div>
                </div>`
            // console.log(k)
            $("#unqualifiedDescription" + num1).parent("td").parent("tr").children(".serialTime" + num2).html(html)
            num2++;
        }
        if (num2 > 3) {
            num2 = 1;
            num1++;
        }
    })
}

function setContent(json) {
    if (navigator.userAgent.indexOf('Chrome') > -1) {
        return;
    }
    Object.keys(jsonText).forEach(function (v, k) {
        console.log(v)
        if (json[v] == "") {
            app.$data.riContent[v] = "&emsp;"
            console.log(app.$data.riContent[v])
        }
        if (jsonText[v]) {
            fontSetForId(v, app.$data.riContent[v])
        }
    })
}

function fontSet(e) {
    if (navigator.userAgent.indexOf('Chrome') > -1) {
        return;
    }
    let fontAllLength = $(e).data("len") ? $(e).data("len") : 26
    let fontwid = $(e).data("fontwid")
    let size = Number($(e).css("font-size").replace("px", ""))
    let len = $(e).text().length
    let num = (len + fontwid) / fontAllLength
    console.log("fontwid", fontwid)
    console.log("size", size)
    console.log("(len+fontwid)%26", (len + fontwid) % fontAllLength)
    console.log("num", num)
    $(e).css("font-size", (12 - num * 0.8) + "px")
    $(e).parent().css("line-height", (13 - num * 0.8) + "px")
}

function fontSet2(e) {
    // if (navigator.userAgent.indexOf('Chrome') > -1) {
    //     return;
    // }
    let fontAllLength = $(e).data("len") ? $(e).data("len") : 26
    let fontwid = $(e).data("fontwid")
    let size = Number($(e).css("font-size").replace("px", ""))
    let len = $(e).parent().text().length
    console.log("len:", len)
    console.log("text:", $(e).parent().text())
    let num = (len) / fontAllLength
    num = num <= 1 ? num - 1 : num
    // $(e).css("font-size", (12 - num * 0.8) + "px")
    $(e).parent().css("font-size", (12 - num * 0.8) + "px")
    $(e).parent().css("line-height", (13 - num * 0.8) + "px")
}

function fontSetForId(name, value) {
    console.log("chuanguolai : ", name)
    let fontAllLength = $("#" + name).data("len") ? $("#" + name).data("len") : 26
    let fontwid = $("#" + name).data("fontwid")
    let size = Number($("#" + name).css("font-size").replace("px", ""))
    let len = value.length
    let num = (len + fontwid) / fontAllLength
    $("#" + name).css("font-size", (12 - num * 0.8) + "px")
    $("#" + name).parent().css("line-height", (13 - num * 0.8) + "px")
}
//‰焦点补充
// $("#report span").focus(function () {
//     // console.log("获得焦点")
//     // let text = $(this).html()
//     // console.log("emsp",text.length)
//     // text = text.replace(/ /g,"")
//     // $(this).text(text)
//     // if (text.indexOf("&emsp;") > -1) {
//     //     console.log(text.indexOf("&emsp;"))
//     // }
//     $(this).html("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;")
// });

$("#report span").blur(function () {
    console.log("失去焦点")
    if ($(this).text() == "") {
        $(this).html("&emsp;")
    }
});

window.addEventListener('keydown', function (e) {
    if (e.keyCode == 83 && (navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey)) {
        e.preventDefault();
        app.saveReport();
    }
})

